package com.example.zzm.yuejian03.Activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.example.zzm.yuejian03.Adapter.MovieAdapter;
import com.example.zzm.yuejian03.Bean.MovieBean;
import com.example.zzm.yuejian03.Listener.MovieListener;
import com.example.zzm.yuejian03.Model.MovieModel;
import com.example.zzm.yuejian03.R;

import java.util.List;

public class MovieActivity extends AppCompatActivity implements View.OnClickListener {

    private RecyclerView recyclerView;
    private TextView textView11;

    public void  onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_movie);
        initViews();
        initEvent();
        int club_id = getIntent().getIntExtra("club_id",1);
        MovieModel classModel = new MovieModel();
        classModel.getMovieList(club_id,listener);
//      ClassModel ClubModeldetails = new ClassModel();
//      ClubModeldetails.getClassList(getIntent().getIntExtra("club_id",1),listener);
    }

    MovieListener listener = new MovieListener() {
        @Override
        public void onResponse(List<MovieBean> beanlist) {
            MovieAdapter classAdapter = new MovieAdapter(getApplicationContext(),beanlist);
            recyclerView.setAdapter(classAdapter);
        }

        @Override
        public void onFail(String msg) {

        }
    };

    private void initEvent() {

        textView11.setOnClickListener(this);
    }

    private void initViews() {
        textView11 = (TextView)findViewById(R.id.textView11);
        recyclerView = (RecyclerView)findViewById(R.id.recyclerview);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this.getApplicationContext());
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.textView11:
                finish();
                break;
        }
    }
}
